<template>
	<view>
		<view class="fixed-header">
			<view :style="{height: topH+'px'}"></view>
			<view :style="{height: navH+'px'}">
				<view class="back" @click="headleTo">back</view>
				<view class="title">{{title}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "nav_bar",
		props: ['title'],
		data() {
			return {
				topH: 20,
				navH: 35
			}
		},
		methods: {
			headleTo() {
				uni.navigateBack()
			}
		}
	}
</script>

<style scoped lang="scss">
	.fixed-header {
		background: #0e932e;
		position: fixed;
		/* 固定头部 */
		width: 100%;
		/* 宽度占满整个视口 */
		z-index: 999;
		/* 确保头部在最顶层 */
	}

	.title {
		color: white;
		font-size: 18px;
		text-align: center;
		line-height: 35rpx;
	}

	.back {
		position: absolute;
		left: 10px;
		top: 50%;
		transform: translateY(-50%);
		color: white;
		font-size: 14px;
		cursor: pointer;
	}
</style>